﻿using ConfExpert.Forms.Base;
using DevExpress.Utils;
using DevTeam;

using System;
using System.Drawing;

namespace ConfExpert.Forms.Aksesuar
{
    public partial class AksesuarAcikTalepler : XForm
    {
        public AksesuarAcikTalepler()
        {
            InitializeComponent();
        }

        private void AcikTalepler_Load(object sender, EventArgs e)
        {
            this.Text = "Açık Çıkış Talepleri";

            gvAksesuar.Init("GetAcikAksesuarCikislari", WhoAmI);

            gvAksesuar.FormatAsNumber(0, "Talep", "Cikilan", "Kalan", "CikilabilirMiktar");
            gvAksesuar.AddSummary("Talep", "Cikilan", "Kalan");

            gvAksesuar.BestFitColumns();
            gvAksesuar.RowCellStyle += gvAksesuar_RowCellStyle;
            bbiGuncelle.ItemClick += bbiGuncelle_ItemClick;
        }

        void bbiGuncelle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gvAksesuar.RefreshDataSource("GetAcikAksesuarCikislari", WhoAmI);
        }

        void gvAksesuar_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.RowHandle>-1)
            {
                string Durum = gvAksesuar.GetRowCellValue(e.RowHandle, "Durum").ToStr();
                if (Durum == "Eksik")
                    e.Appearance.BackColor = Color.Pink;

                switch (e.Column.FieldName)
                {
                    case "Kalan":
                        e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
                        return;
                }
            }             
        }
    }
}
